/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved.
 * Description: local ipc rma buffer implement
 */

#ifndef LOCAL_IPC_RMA_BUFFER_IMPL_H
#define LOCAL_IPC_RMA_BUFFER_IMPL_H

#include "hccl_common.h"
#include "hccl_network_pub.h"
#include "rma_buffer.h"
#include "mem_name_repository_pub.h"

namespace hccl {
class LocalIpcRmaBufferImpl : public RmaBuffer {
public:
    LocalIpcRmaBufferImpl(const HcclNetDevCtx netDevCtx, void* addr, u64 size, const HcclMemType memType);
    ~LocalIpcRmaBufferImpl();

    LocalIpcRmaBufferImpl(const LocalIpcRmaBufferImpl &that) = delete;
    LocalIpcRmaBufferImpl &operator=(const LocalIpcRmaBufferImpl &that) = delete;

    HcclResult Init();
    HcclResult Destroy();

    std::string Serialize();

    HcclResult Grant(u32 remotePid, u32 remoteSdid);

private:
    const           HcclNetDevCtx netDevCtx{nullptr};
    s32             deviceLogicId{-1};
    SecIpcName_t    memName;
    u64             memOffset{0};
    bool initialized_ = false;
};
}
#endif //  LOCAL_IPC_RMA_BUFFER_IMPL_H